package org.fast.easy.messages.controller;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.fast.easy.core.domain.result.R;
import org.fast.easy.framework.web.core.BaseController;
import org.fast.easy.core.domain.messages.MessagePublishDomain;
import org.fast.easy.messages.service.IMessageService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 邮件功能
 *
 * @author Lion Li
 */
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/message")
public class SysMessageController extends BaseController {
    private final IMessageService messageService;

    /**
     * 推送消息
     * @param message
     * @return
     */
    @PostMapping("/publishAll")
    public R<Void> publishAll(MessagePublishDomain message) {
        if(messageService.publishAll(message)){
            return R.ok();
        }
        return R.fail();
    }

}
